package org.jimmy.tang.innerclass;

/**
 * @author jimmy
 * 
 */
public class StaticInnerclassDemo {
    public static void main(String... arg) {
        OuterClass2 p = new OuterClass2();
        p.fo();// com.xujin.OuterClass2
        OuterClass2.StaticInnerClass i = new OuterClass2.StaticInnerClass(p);
        i.shuchu("world!");// Hello,world!
        i.getClassName();// com.xujin.OuterClass2$StaticInnerClass

        // OuterClass2.InnerClass ic = new
        // OuterClass2.InnerClass();//error,这里OuterClass2.InnerClass不是一个类型type，类比静态域和非静态域
        p.new InnerClass().getClassName();// com.xujin.OuterClass2$InnerClass
    }
}

class OuterClass2 {
    static class StaticInnerClass {
        StaticInnerClass(OuterClass2 outerClass) {
            outer = outerClass;
        }

        public void shuchu(String name) {

            System.out.println("Hello," + name);
        }

        public void getClassName() {
            System.out.println(this.getClass().getName());
        }

        private OuterClass2 outer;
    }

    class InnerClass {
        public void getClassName() {
            System.out.println(this.getClass().getName());
        }
    }

    public void fo() {
        System.out.println(this.getClass().getName());
    }

    private int OuterPar;
}
